
import lejos.nxt.*;
import lejos.subsumption.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Fredrik
 */
public class Touch implements SensorPortListener {
    private TouchSensor touch;
    private Control control;
    
    	String changed = "State changed";
	String val = "Value:";
	String oldVal = "old Value:";
	String free = "Free Mem:"; 
    
    public Touch(Control control) throws InterruptedException {
        this.touch = new TouchSensor(SensorPort.S1);
        this.control = control;
    }
    
    
    public void stateChanged(SensorPort port, int value, int oldValue) {
     /*   if(port == SensorPort.S1) {
            if(touch.isPressed()) {
                //pressed
                control.doCommand("closegrip");
                control.setGripState(true); //set to closed
            } else {
                //not pressed
                control.doCommand("opengrip");
                control.setGripState(false); //set to opened
            }  
        }*/
    }
    
    public void startListener() throws InterruptedException {
	SensorPort.S1.addSensorPortListener(this);
    }
    
    public boolean getIsPressed(){
    	boolean retBool;
    	
    	if(touch.isPressed())
    		retBool = true;	
    	else
    		retBool = false;
    	return retBool;
    }

}
